package com.doudou.feign;

import com.netflix.hystrix.HystrixCommand;
import feign.Feign;
import feign.hystrix.HystrixFeign;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;

/**
 * @Author: 傻男人
 * @Date: 2020/5/25 11:28
 * @Version: 1.0
 * @Description: Feign默认失败处理自动配置类
 */
@Configuration
@ConditionalOnClass({HystrixCommand.class, HystrixFeign.class})
public class FeignDefaultFallbackFactoryAutoConfiguration {

    @Bean
    @Scope("prototype")
    @ConditionalOnClass({Feign.class})
    @ConditionalOnProperty(name = "custom.feign.defaultFallback.enabled",havingValue = "true",matchIfMissing = false)
    @Primary
    public Feign.Builder feignSentinelBuilder() {
        return new CustomFeignBuilder();

    }
}